#include<iostream> 
#include<string>
using namespace std;

int main()
{
    string T,W;
    int n,i,count;
    cin>>n;
    i = 0;
    while(i<n)    
    {
        i++;
        cin>>W>>T;
        basic_string <char> t;
        count = 0;
        for(int j=0;j<T.length()-W.length()+1;j++)              
        {
            t = T.substr(j,W.length());                    
            if(t==W)  count++;
        } 
        
        cout<<count<<endl;
    }
    
    //system("pause");
    return 0;
}
